<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <div id="root">
    <input type="text" id="a" value="1">+
    <input type="text" id="b" value="2">+
    <button>=</button>
    <input id="sum" type="text">
  </div>
</body>
<script>
    document.querySelector("button").onclick = function(){
        const a = document.querySelector("#a");
        const b = document.querySelector("#b");
        const xhr = new XMLHttpRequest();
        xhr.responseType = "json";
        xhr.open("get",`/sum?a=${a.value}&b=${b.value}`);
        xhr.send();
        xhr.onload = function(){
            document.querySelector("#sum").value = xhr.response.sum;
        }
    }
</script>
</html>